home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / hexstrin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  934 b   |  40 lines

  1. /*
  2. \funcref{hexstring}{char $*$hexstring (\params)}
  3.     {
  4.         {UNS16} {val} {value to convert}
  5.         {UNS16} {len} {requested string length}
  6.     }
  7.     {stringrepresentation of {\em val}}
  8.     {}
  9.     {}
  10.     {hexstrin.c}
  11.     {
  12.  
  13.         This function converts a value {\em val} to hexadecimal representation
  14.         in a string with length {\em len}. The string may be preceded by zero's
  15.         to ensure the length.
  16.  
  17.         The result of the conversion is stored in a static buffer, which is
  18.         returned. Repetitive calls to {\em hexstring()} will overwrite this
  19.         buffer.
  20.  
  21.         {\bf Note that} {\em len} may not exceed 9. The size of the static
  22.         buffer is only 10 chars.
  23.  
  24.     }
  25. */
  26.  
  27. #include "icrssdef.h"
  28.  
  29. char *hexstring (UNS16 val, UNS16 len)
  30. {
  31.     static char
  32.         retbuf [10];
  33.     char
  34.         buf [10];
  35.  
  36.     sprintf (buf, "%%%d.%dx", len, len);
  37.     sprintf (retbuf, buf, val);
  38.     return (retbuf);
  39. }
  40.